﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
///PageInfo 的摘要说明
/// </summary>

public class PageInfo
{
    /// <summary>
    /// 存放URL信息
    /// </summary>
    public string URL { get; set; }
    /// <summary>
    /// 存放分组显示字段信息
    /// </summary>
    public GroupFields GroupField { get; set; }

    /// <summary>
    /// 当前页面的标题
    /// </summary>
    public string Title { get; set; }

    public override bool Equals(object obj)
    {
        if (obj is PageInfo)
        {
            PageInfo other = obj as PageInfo;
            return other.URL == URL;

        }
        else
        {
            return false;
        }

        // return base.Equals(obj);
    }
}

public class URLControl
{

    #region 保存菜单标志
    private const string MenuFlag = "MenuFlag";

    private const string DefaultTitle = "采购汇总统计";
    public static string GetMenuFlag()
    {
        return HttpContext.Current.Session[MenuFlag] == null ? DefaultTitle : HttpContext.Current.Session[MenuFlag].ToString();
    }

    public static void SetMenuFlag(string title)
    {
        HttpContext.Current.Session[MenuFlag] = title;
    }

    #endregion 保存菜单标志



    /// <summary>
    /// 存放与菜单对应的页面信息
    /// </summary>
    private static Dictionary<string, PageInfo> dic;

    public static PageInfo GetPageInfo(string name)
    {
        try
        {
            return dic[name];
        }
        catch (Exception e)
        {
            // return CurrentUserInfo; 
            return HosComDrugs;
        }
    }

    static URLControl()
    {
        dic = new Dictionary<string, PageInfo>(30);

        #region 页面类别
        dic.Add("1", TradeStatic);
        dic.Add("2", HospitaStatic);
        dic.Add("3", ProcureCatalogID);
        dic.Add("4", HospitalOrderStatic);
        dic.Add("5", HospitalBuyNum);
        dic.Add("6", DrugsBuyNum);

        dic.Add("8", OrderTradeRate);
        dic.Add("9", UnTradeProduct);
        dic.Add("10", ExpensiveDrugs);
        dic.Add("11", ExpensiveDrugsSet);
        dic.Add("15", InsuranceType);

        dic.Add("16", CompanyID_PS);
        dic.Add("17", CompanyName_SC);

        dic.Add("18", NoSendOnTimeCompany);
        dic.Add("19", MonthHospital);

        dic.Add("51", WarningSetup);
        dic.Add("52", WarningMap);
        dic.Add("53", WarningDeal);
        dic.Add("54", Whitelist);


        #endregion
    }

    /// <summary>
    /// 黑名单
    /// </summary>
    public static PageInfo Whitelist
    {
        get {
            return GetPageInfo("Whitelist",GroupFields.PurchaseCountTotal,"黑名单");
        }
    }

    /// <summary>
    /// 预警设置
    /// </summary>
    public static PageInfo WarningSetup
    {
        get
        {
            return GetPageInfo("WarningSetup", GroupFields.PurchaseCountTotal, "预警设置");
        }
    }
    /// <summary>
    /// 预警地图
    /// </summary>
    public static PageInfo WarningMap
    {
        get
        {
            return GetPageInfo("WarningMap", GroupFields.PurchaseCountTotal, "预警地图");
        }
    }

    /// <summary>
    /// 预警处理
    /// </summary>
    public static PageInfo WarningDeal
    {
        get
        {
            return GetPageInfo("WarningDeal", GroupFields.PurchaseCountTotal, "预警处理");
        }
    }

    /// <summary>
    /// 贵重药品设置
    /// </summary>
    public static PageInfo ExpensiveDrugsSet
    {
        get
        {
            return GetPageInfo("ExpensiveDrugsSet", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal, "贵重药品设置");
        }
    }



    /// <summary>
    /// 子用户模块
    /// </summary>
    public static PageInfo ChildUserList
    {
        get
        {
            PageInfo pi = new PageInfo();
            pi.URL = "~/Admin/ChildUserList.aspx";
            pi.Title = "子用户管理";
            pi.GroupField = GroupFields.WareHouseCountTotal;
            return pi;
        }
    }


    /// <summary>
    /// 未采购药品统计
    /// </summary>
    public static PageInfo UnTradeProduct
    {
        get
        {
            return GetPageInfo("UnTradeProduct", GroupFields.PurchaseCountTotal | GroupFields.PurchaseAmountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "未采购药品统计");
        }
    }


    /// <summary>
    /// 医院月采购信息统计
    /// </summary>
    public static PageInfo MonthHospital
    {
        get
        {
            return GetPageInfo("MonthHospital", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal, "医院月采购信息统计");
        }
    }

    /// <summary>
    /// 订单成交比率统计
    /// </summary>
    public static PageInfo OrderTradeRate
    {
        get
        {
            return GetPageInfo("OrderID", GroupFields.WareHouseRate | GroupFields.WareHouseAmountTotal, "订单成交比率统计");
        }
    }

    /// <summary>
    /// 贵重药品采购统计
    /// </summary>
    public static PageInfo ExpensiveDrugs
    {
        get
        {
            return GetPageInfo("ExpensiveDrugs", GroupFields.PurchaseAmountTotal, "贵重药品采购统计");
        }
    }

    /// <summary>
    /// 交易汇总统计
    /// </summary>
    public static PageInfo TradeStatic
    {
        get
        {
            return GetPageInfo("HosComDrugs", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseRate, "交易汇总统计");
        }
    }

    /// <summary>
    /// 医院汇总统计
    /// </summary>
    public static PageInfo HospitaStatic
    {
        get
        {
            return GetPageInfo("HospitalID", GroupFields.PurchaseCountTotal | GroupFields.PurchaseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseRate, "医院汇总统计");
        }
    }

    /// <summary>
    /// 药品汇总统计
    /// </summary>
    public static PageInfo ProcureCatalogID
    {
        get
        {
            return GetPageInfo("ProcureCatalogID", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "药品汇总统计");
        }
    }

    /// <summary>
    /// 医院采购单查询
    /// </summary>
    public static PageInfo HospitalOrderStatic
    {
        get
        {
            return GetPageInfo("OrderID", GroupFields.PurchaseAmountTotal | GroupFields.WareHouseAmountTotal, "医院采购单统计");
        }
    }

    /// <summary>
    /// 医院采购次数统计
    /// </summary>
    public static PageInfo HospitalBuyNum
    {
        get
        {
            return GetPageInfo("HospitalID", GroupFields.PurchaseAmountTotal | GroupFields.CountOrder, "医院采购次数统计");
        }
    }

    /// <summary>
    /// 药品采购次数
    /// </summary>
    public static PageInfo DrugsBuyNum
    {
        get
        {
            return GetPageInfo("ProcureCatalogID", GroupFields.PurchaseAmountTotal | GroupFields.CountOrder, "药品采购次数统计");
        }
    }


    /// <summary>
    /// 医保药品统计
    /// </summary>
    public static PageInfo InsuranceType
    {
        get
        {
            return GetPageInfo("InsuranceType", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "医保药品统计");
        }
    }


    /// <summary>
    /// 配送企业汇总统计
    /// </summary>
    public static PageInfo CompanyID_PS
    {
        get
        {
            return GetPageInfo("CompanyID_PS", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseRate, "配送企业汇总统计");
        }
    }

    /// <summary>
    /// 生产企业汇总统计
    /// </summary>
    public static PageInfo CompanyName_SC
    {
        get
        {
            return GetPageInfo("CompanyName_SC", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "生产企业汇总统计");
        }
    }

    public static PageInfo AreaID
    {
        get
        {
            return GetPageInfo("AreaID", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "按地区查看");
        }
    }


    public static PageInfo SortID
    {
        get
        {
            return GetPageInfo("SortID", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "按药品类别查看");
        }
    }


    private static PageInfo GetPageInfo(string key, GroupFields fields, string title)
    {
        PageInfo pi = new PageInfo();

        pi.URL = System.Configuration.ConfigurationManager.AppSettings[key];
        pi.Title = title;
        pi.GroupField = fields;

        return pi;
    }


    /// <summary>
    /// 采购详细信息
    /// </summary>
    public static PageInfo DetailInfo
    {
        get
        {

            return GetPageInfo("DetailInfo", GroupFields.PurchaseAmountTotal, "采购详细信息");
        }
    }

    public static PageInfo HosComDrugs
    {
        get
        {
            return GetPageInfo("HosComDrugs", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "交易汇总统计");
        }
    }

    public static PageInfo CompanyName_TB
    {
        get
        {
            return GetPageInfo("CompanyName_TB", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "按投标企业查看");
        }
    }


    public static PageInfo QualityLevel
    {
        get
        {
            return GetPageInfo("QualityLevel", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal | GroupFields.WareHouseRate, "按质量层次查看");
        }
    }

    /// <summary>
    /// 当月未按时配送企业名单统计
    /// </summary>
    public static PageInfo NoSendOnTimeCompany
    {
        get
        {//此处分组字段是页面固定的
            return GetPageInfo("NoSendOnTime", GroupFields.PurchaseAmountTotal | GroupFields.PurchaseCountTotal | GroupFields.WareHouseAmountTotal | GroupFields.WareHouseCountTotal, "当月未按时配送企业名单统计");
        }
    }


}




